import axios from 'axios'
import { baseURL } from '../baseurl'

export default function downLoadFile(url) {
    console.log("/root/file/"+url)
    let newURL = "/root/file/"+url

    return axios.get(baseURL + `/team/downloadOne?url=${newURL}`,{
        responseType: 'arraybuffer',
    }).then(res => {
        let a = document.createElement('a');
 
        //ArrayBuffer 转为 Blob
        let blob = new Blob([res.data], {type: "application/vnd.ms-excel"})
              
        let objectUrl = URL.createObjectURL(blob)
        a.setAttribute("href",objectUrl)
        let filename = url.split("/")
        console.log(filename)
        // a.setAttribute("download", url)
        a.setAttribute("download", filename)
        a.click()
    })

}